package com.wzx.service;

import com.wzx.dao.IAccountDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Isolation;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

@Service
//@Transactional(isolation = Isolation.REPEATABLE_READ ,propagation = Propagation.REQUIRED ,timeout = -1)
public class AccountServiceImpl implements IAccountService{
    @Autowired
    IAccountDao dao ;
    @Transactional(isolation = Isolation.REPEATABLE_READ ,propagation = Propagation.REQUIRED ,timeout = -1)
    @Override
    public void translate(String from, String to, double money) {
        //创建AccountDaoImpl
        //AccountDaoImpl dao = new AccountDaoImpl();
        //调用方法

        dao.translateOut(from,money);
        System.out.println(1/0); //断电
        dao.translateIn(to,money);
        System.out.println("--translate");
    }
}
